package com.su.gulimall.search.thread;

import java.util.concurrent.*;
/*.thenRunAsync(() -> {
        System.out.println("任务2启动了");
        }, executor);*/
public class ChuanXing {
    public static ThreadPoolExecutor executor = new ThreadPoolExecutor(
            5,200,10,
            TimeUnit.SECONDS,new LinkedBlockingDeque<>(100000),
            Executors.defaultThreadFactory(),new ThreadPoolExecutor.AbortPolicy());
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        System.out.println("main线程开始-------");
        //有返回值，executor
        CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> {
            System.out.println("当前线程:" + Thread.currentThread().getId());
            int i = 10 / 4;
            System.out.println("运行结果为：" + i);
            return i;
        }, executor).thenApplyAsync(res -> {
            System.out.println("任务2启动了：" + res);
            return "hello" + res;
        }, executor);
        System.out.println("main---end----"+future.get());
    }
}
